<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CRM 销售管理系统/登录</title>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CRM销售管理系统</title>
    <link rel="stylesheet" href="/static/bs/css/bootstrap.css">
    <link rel="stylesheet" href="/static/css/customer_list.css">
    <script src="/static/js/jquery-3.5.1.js"></script>
</head>
<body>
<nav class="navbar navbar-default header clearfix">
    <div class="container-fluid">
        <div class="navbar-header">
        </div>
        <span class="info" style="font-size: 30px;color: white">CRM销售管理系统</span>
    </div>
</nav>
<div class="container">
    <div class="row">
        <div class="col-md-3 col-md-offset-4">
            <div class="panel panel-primary" style="margin-top: 10px">
                <div class="panel-heading"><span>用户登录</span>
                </div>
                <form>
                    {% csrf_token %}
                    <div class="form-group">
                        <label for="">Username</label>
                        <input  type="text" class="form-control" id="username">
                    </div>
                    <div class="form-group">
                        <label for="">Password</label>
                        <input type="password" class="form-control" id="password">
                    </div>
                    <button type="button" class="btn btn-success " id="btn">login</button>
                    <span id="msg" style="color: red"></span>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $('#btn').click(function () {
        $.ajax({
            url:'',
            type:'post',
            data:{
                'user' :$('#username').val(),
                'pwd':$('#password').val(),
                'csrfmiddlewaretoken':$('[name="csrfmiddlewaretoken"]').val(),
            },
            success:function (data) {
                if (data['msg']){
                    window.location.href='/index/'
                }else {
                    $('#msg').html('用户名或密码错误')
                    setTimeout(function () {
                         $('#msg').html('')
                    },1000)
                }
            }
        })
    })
</script>
</body>
